package com.magenta.maxoptra.gis;

import static com.magenta.maxoptra.gis.GISFieldType.BOOLEAN;
import static com.magenta.maxoptra.gis.GISFieldType.TEXT;
import static com.magenta.maxoptra.gis.GisParameter.*;

/**
 * User: KuznetsovD
 * Date: 25.10.11
 * Time: 16:14
 */
public enum GoogleMapAttribute implements GISAccountProperty {
    UseProvider(GisParameter.use_map_provider, MapProviderType.google, GISFieldType.BOOLEAN, "false", true, 0L, true),
    GoogleForwardGeocodingUrl(base_url, MapProviderType.google, TEXT,
            "http://maps.google.com/maps/geo?q={0}&output={1}&key={2}", false, 1L, true),
    GoogleReverseGeocodingUrl(reverse_geocoding_url, MapProviderType.google, TEXT,
            "http://maps.google.com/maps/geo?output={0}&oe=utf-8&ll={1}%2C{2}&key={3}", false, 2L, true),
    GoogleRoutingUrl(routing_url, MapProviderType.google, TEXT,
            "http://maps.google.com/maps/nav?key={0}&q=from:{1}, {2} to:{3}, {4}", false, 3L, true),
    GoogleMapKey(map_key, MapProviderType.google, TEXT,
            "ABQIAAAA_E_JxZZDT3oHcFgZIxNv6hQJ24fKfMoWP075efM0BdoW5cn_zhQ5aAmkgqoo9nIXkabOd7t4wCZSxw", false, 4L, true),
    GoogleGeocodingKey(geocoding_key, MapProviderType.google, TEXT,
            "ABQIAAAA_E_JxZZDT3oHcFgZIxNv6hRtwqDAiWXzJqDpqFeVF2OTC0GH6BQDOrU0NrAcjpOnzg62f3KgeZlEgQ", false, 5L, true),
    GoogleMapDomain(domain, MapProviderType.google, TEXT, "test2.maxoptra.com", false, 6L, true),
    GoogleUseMapKey(use_map_key, MapProviderType.google, BOOLEAN, "true", true, 7L, true),
    GoogleUseCustomGeoAddressForm(use_custom_geo_address_form, MapProviderType.google, BOOLEAN, "false", true, 8L, true),
    GoogleEnableLog(enableLogging, MapProviderType.google, BOOLEAN, "false", false, 10L, true),
    GoogleEnableCache(enableCache, MapProviderType.google, BOOLEAN, "true", true, 11L, true),
    GoogleCacheStorageTime(cacheStorageTime, MapProviderType.google, GISFieldType.INTEGER, "200", true, 14L, true),
    GooglemapAccuracy(geocoding_accuracy, MapProviderType.google, TEXT, "STREET_LEVEL", true, 12L, true),
    GooglemapUseMultiplePointsRouting(useMultiplePointsRouting, MapProviderType.google, GISFieldType.BOOLEAN, "false", false, 13L, true);

    private String name;
    private String label;
    private Long order;
    private GISFieldType type;
    private String defaultValue;
    private boolean required;
    private String groupName;
    private String tab = "GIS";
    private boolean important = true;

    public boolean isImportant() {
        return important;
    }

    public String getName() {
        return name;
    }

    public GISFieldType getType() {
        return type;
    }

    public String getDefaultValue() {
        return defaultValue;
    }

    public Boolean getMandatory() {
        return required;
    }

    public String getGroup() {
        return groupName;
    }

    public String getLabel() {
        return label;
    }

    public Long getOrder() {
        return order;
    }

    public String getTab() {
        return tab;
    }

    private GoogleMapAttribute(String name, String label, GISFieldType type, String defaultValue,
                               boolean required, String groupName, Long order, boolean important) {
        this.name = name;
        this.label = label;
        this.type = type;
        this.defaultValue = defaultValue;
        this.groupName = groupName;
        this.required = required;
        this.order = order;
        this.important = important;
    }

    private GoogleMapAttribute(GisParameter parameter, MapProviderType providerType, GISFieldType type,
                               String defaultValue, boolean required, Long order, boolean important) {
        this(parameter.withProvider(providerType.name()),
                parameter.getLabel(),
                type,
                defaultValue,
                required,
                providerType.getLabel(),
                order, important);
    }

    public boolean isReadOnly() {
        return false;
    }

}
